# import numpy as np
# import cv2 as cv
# im=np.zeros((300,300,3),np.uint8)
# im[100:200,100:200]=255
# imgray =cv.cvtColor(im,cv.COLOR_BGR2GRAY)
# ret,thresh=cv.threshold(imgray,127,255,0)
# retrievalMode =cv.RETR_TREE
# approxMethod=cv.CHAIN_APPROX_NONE
# contours,hierarchy=cv.findContours(thresh,retrievalMode,approxMethod)

import numpy as np
import cv2 as cv
im =np.zeros((300,300,3),np.uint8)
im[100:200,100:200]=255
imgray =cv.cvtColor(im,cv.COLOR_BGR2GRAY)

ret,thresh=cv.threshold(imgray,127,255,0)

retrievalMode =cv.RETR_TREE
approxMethod =cv.CHAIN_APPROX_SIMPLE
contours, hierarchy = cv.findContours(thresh, retrievalMode, approxMethod)
#draw contours
img2 =np.zeros((300,300,3),np.uint8)
cnt = contours[0]

radius =2
color,thickness=(0,0,255),1
for pt in cnt:
   center = pt[0]
   cv.circle(img2,center,radius,color,thickness)
cv.imshow("im",im)
cv.imshow("img2",img2)
cv.waitKey(0)
cv.destroyAllWindows()